package com.nes.rabbitmq.springboot.object;

import com.nes.rabbitmq.springboot.User;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;

/**
 * Created by wdq on 17-3-13.
 */
@Service
//注册队列的监听-指定队列名称
@RabbitListener(queues = "spring-queue-object",containerFactory="rabbitListenerContainerFactory")
public class ReceiverObject {


    @RabbitHandler
    public void process(@Payload User user) {
        System.out.println("Received user <" + user + ">");

    }

    @RabbitHandler
    public void process(@Payload String message) {
        System.out.println("Received string <" + message + ">");
    }
}
